package baseFx.common.services;

public class DefaultServiceContext extends AbstractServiceContext {
    @Override
    public void use(ServiceObject serviceObject, Object state) {
        ServiceObjectArgs e = new ServiceObjectArgs(serviceObject, this);
        onBefore(e);
        if (e.cancel == false) {
            try {
                executeSo(serviceObject, state);
            } catch (Exception ex) {
                serviceObject.onError(ex);
                ServiceObjectErrorArgs args = new ServiceObjectErrorArgs(serviceObject, this, ex);
                onError(args);
                throw ex;
            }
        }
        onAfter(e);
    }
}
